home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Science / RLaB / rlib / num2str.r < prev    next >
Text File  |  1994-04-25  |  583b  |  28 lines

  1. //-------------------------------------------------------------------//
  2.  
  3. //  Syntax:    num2str ( N )
  4.  
  5. //  Description:
  6.  
  7. //  Num2str converts the scalar-numeric argument into a string, which
  8. //  is the return value. 
  9. //-------------------------------------------------------------------//
  10.  
  11. num2str = function ( N )
  12. {
  13.   local (s)
  14.  
  15.   if (class (N) == "num" && type (N) == "real")
  16.   {
  17.     if (N.n == 1) 
  18.     { 
  19.       sprintf (s, "%.4g", N);
  20.       return s
  21.     else
  22.       error ("num2str: argument must be scalar");
  23.     }
  24.   else
  25.     error ("num2str: argument must be numeric-real");
  26.   }
  27. };
  28.